package edu.rit.checkers;

import java.io.PrintStream;

/**
 * Used to print to a given print stream.  Good for putting print statements in
 * code that you can turn on and off.
 * 
 * @author Ian Tewksbury (ict8574@rit.edu)
 */
public class Logger {
	private boolean loggerOn;
	private PrintStream out;
	
	/**
	 * create a new logger.
	 * 
	 * @param out the stream this logger will write too
	 */
	public Logger(PrintStream out) {
		this.loggerOn = true;
		this.out = out;
	}
	
	/**
	 * Tell the logger whether it is on or off.
	 * 
	 * @param loggerOn if true turns logger on, if false turns it off
	 */
	public void loggerOn(boolean loggerOn) {
		this.loggerOn = loggerOn;
	}
	
	/**
	 * Print a line to the logger
	 * 
	 * @param obj object to print to the loggers stream with an appended newline
	 */
	public void println(Object obj) {
		if(this.loggerOn) {
			out.println(obj);
		}
	}
	
	/**
	 * Print an object to the logger
	 * 
	 * @param obj object to print to the loggers stream
	 */
	public void print(Object obj) {
		if(this.loggerOn) {
			out.print(obj);
		}
	}
}
